home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
APC & TCP 4
/
APC & TCP 4.iso
/
games
/
publicdomain
/
a
/
attacks
/
sources
/
attacksgraphics.mod
< prev
next >
Wrap
Text File
|
1994-05-14
|
45KB
|
1,089 lines
IMPLEMENTATION MODULE attacksgraphics;
(*$R-V-*) (* range checking OFF, overflow checking OFF *)
(* This is the implementation module of all the graphics stuff for my
ataxx program.
*)
(**************************************************************)
FROM TermInOut
IMPORT WriteString, WriteLn;
FROM SYSTEM
IMPORT BYTE, ADR, LONGWORD, ADDRESS;
FROM Memory
IMPORT AllocMem, FreeMem, MemReqSet, MemChip, MemClear;
FROM Preferences
IMPORT Preferences, GetPrefs;
FROM Views
IMPORT ViewModesSet, Sprites, LoadRGB4, SetRGB4, ViewPort, ColorTable,
GetRGB4;
FROM Rasters
IMPORT RastPort, Jam1, Jam2;
FROM Drawing
IMPORT SetAPen, SetOPen, SetDrMd, Draw, Move, RectFill, DrawCircle,
WritePixel, ReadPixel;
FROM header
IMPORT boardtype, playertype, squaretype, boardrange, state, pointercode,
movetype, printmsgtype;
FROM input
IMPORT WaitForMouseUp, ChangeToMainMenu;
FROM attackssprites
IMPORT InitPointers, circle, mypointer, emptysquare, blocksquare;
FROM Ports
IMPORT GetMsg, ReplyMsg, MsgPortPtr, WaitPort, MessagePtr;
FROM Conversions
IMPORT ConvNumberToString;
FROM Intuition
IMPORT NewScreen, OpenScreen, ScreenPtr, Screen, CustomScreen,
CloseScreen, NewWindow, WindowPtr, WindowFlagsSet,
IDCMPFlagsSet, OpenWindow, CloseWindow, ClearMenuStrip,
WindowFlags, IDCMPFlags, ScreenFlags, IntuiMessagePtr,
SetPointer, ClearPointer, IntuiText, PrintIText, ShowTitle;
(***********************************************************************)
CONST
Black = 0;
White = 1;
BGrey = 2;
Red = 3; DarkRed = 4; LtRed = 5;
Blue = 6; DarkBlue = 7; LtBlue = 8;
HGrey = 9; HDarkGrey = 10; HLtGrey = 11;
Green = 14; DarkGreen = 13; LtGreen = 12; (* other colors *)
Yellow = 15; DarkYellow = 16; LtYellow = 18;
Orange = 18; DarkOrange = 19; LtOrange = 20;
Purple = 21; DarkPurple = 22; LtPurple = 23;
Violet = 24; DarkViolet = 25; LtViolet = 26;
Cyan = 27; DarkCyan = 28; LtCyan = 29;
VAR
ns : NewScreen; (* The screen and graphics vars *)
myscreenptr : ScreenPtr;
myrastport : RastPort;
myviewport : ViewPort;
mycolortable : ColorTable;
nw : NewWindow; (* The backdrop window vars *)
itext : IntuiText; (* For displaying text *)
oldmousecolor1, oldmousecolor2, oldmousecolor3 : (* Hold the colors *)
ARRAY [1..3] OF CARDINAL; (* of the original *)
(* mouse. *)
(**************************************************************************)
PROCEDURE InitializeScreen() : BOOLEAN;
(* Starts the graphix running. *)
(* Sets up all the graphics variables and draws the first graphics *)
(* that will be presented. It returns true if all the actions worked, *)
(* false otherwise. *)
(* *)
(* INPUT *)
(* n/a *)
(* *)
(* OUTPUT *)
(* Returns a boolean value that tells if the operation was *)
(* succussful or not. If successful, the screen (along *)
(* with the accompanying graphics) is started. *)
(* *)
(* NOTE: This uses mostly globals to this module. It should *)
(* work fine. *)
VAR
i : CARDINAL;
oldcolor : LONGCARD; (* holds the initial result of GetRGB4 *)
preferences : Preferences;
foo : ADDRESS;
BEGIN
(*******************************)
(* Making new screen structure *)
(*******************************)
ns.LeftEdge := 0; ns.TopEdge := 0;
ns.Width := 320; ns.Height := 200;
ns.Depth := 4;
ns.DetailPen := BYTE(0); ns.BlockPen := BYTE(1);
ns.ViewModes := ViewModesSet{Sprites}; (* Not quite sure about this *)
ns.Type := CustomScreen;
ns.Font := NIL; (* Using default font *)
ns.DefaultTitle := ADR("Attacks");
ns.Gadgets := NIL;
myscreenptr := OpenScreen(ns);
IF myscreenptr = NIL THEN
WriteString ("Couldn't open screen."); WriteLn;
RETURN FALSE;
END;
ShowTitle(myscreenptr^, FALSE); (* Put title BEHIND the backdrop's *)
(**************************************)
(* Get vars for the graphics routines *)
(**************************************)
myrastport := myscreenptr^.RastPort;
myviewport := myscreenptr^.ViewPort;
foo := GetPrefs(ADR(preferences), SIZE(Preferences));
(* Here, I'm getting the default colors for the orig. mouse *)
oldmousecolor1[1] := preferences.color17 DIV 128;
oldmousecolor1[2] := preferences.color17 DIV 8;
oldmousecolor1[3] := preferences.color17;
oldmousecolor2[1] := preferences.color18 DIV 128;
oldmousecolor2[2] := preferences.color18 DIV 8;
oldmousecolor2[3] := preferences.color18;
oldmousecolor3[1] := preferences.color19 DIV 128;
oldmousecolor3[2] := preferences.color19 DIV 8;
oldmousecolor3[3] := preferences.color19;
(************************************)
(* Preparing the ColorMap structure *)
(************************************)
(* Defining the colors *)
mycolortable [0] := 0000H; (* Black *)
mycolortable [1] := 0FFFH; (* White *)
mycolortable [2] := 0AAAH; (* BGrey *)
mycolortable [3] := 0D00H; (* Red *)
mycolortable [4] := 0900H; (* Dark Red *)
mycolortable [5] := 0F55H; (* Light Red *)
mycolortable [6] := 024EH; (* Blue *)
mycolortable [7] := 000AH; (* Dark Blue *)
mycolortable [8] := 066FH; (* Light Blue *)
mycolortable [9] := 0666H; (* HGrey *)
mycolortable [10] := 0444H; (* HDark Grey *)
mycolortable [11] := 0888H; (* HLight Grey *)
mycolortable [12] := 09F9H; (* Light Green *)
mycolortable [13] := 0090H; (* Dark Green *)
mycolortable [14] := 00E0H; (* Green *)
mycolortable [15] := 0EE0H; (* Yellow *)
(* This changes the colors *)
LoadRGB4 (myviewport, ADR (mycolortable), 16);
(*******************************)
(* Now, open a backdrop window *)
(*******************************)
nw.LeftEdge := 0; nw.TopEdge := 0;
nw.Width := 320; nw.Height := 200;
nw.DetailPen := BYTE(-1); nw.BlockPen := BYTE(-1); (* use screen's pens *)
nw.Flags := WindowFlagsSet {BackDrop, Borderless, Activate};
nw.IDCMPFlags := IDCMPFlagsSet {MouseButtons, MenuPick};
nw.FirstGadget := NIL;
nw.CheckMark := NIL;
nw.Title := NIL; (* NO TITLE *)
nw.Type := CustomScreen;
nw.Screen := myscreenptr;
mywindowptr := OpenWindow(nw);
IF mywindowptr = NIL THEN
CloseScreen(myscreenptr^);
WriteString ("Couldn't open window."); WriteLn;
RETURN FALSE;
END;
(***************************)
(* Draw the initial screen *)
(***************************)
(* Set the drawing mode *)
SetDrMd(myrastport, Jam1);
(* Blank the screen *)
SetAPen(myrastport, Black); (* set A pen *)
SetOPen(myrastport, Black); (* and the outline pen too! *)
RectFill(myrastport,0,0,319,199);
(* Drawing a blank board *)
SetAPen(myrastport, BGrey);
SetOPen(myrastport, BGrey);
RectFill(myrastport,52,18,267,198);
i := 82; (* draw vertical lines *)
SetAPen(myrastport, Black); (* black *)
REPEAT
Move(myrastport, i, 18);
Draw(myrastport, i, 199);
i := i + 31;
UNTIL i = 268;
i := 43; (* now the horizontal *)
REPEAT
Move(myrastport, 52, i);
Draw(myrastport, 268, i);
i := i + 26;
UNTIL i = 199;
(*************